package com.water.service.impl;

import com.water.dao.BeHistoryDao;
import com.water.entity.BeHistory;
import com.water.entity.BeOrder;
import com.water.service.BeHistoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (BeHistory)表服务实现类
 *
 * @author makejava
 * @since 2020-12-14 19:18:45
 */
@Service("beHistoryService")
public class BeHistoryServiceImpl implements BeHistoryService {
    @Resource
    private BeHistoryDao beHistoryDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public BeHistory queryById(Integer id) {
        return this.beHistoryDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<BeHistory> queryAllByLimit(int offset, int limit) {
        return this.beHistoryDao.queryAllByLimit(offset, limit);
    }

    @Override
    public List<BeHistory> queryAll(BeHistory beHistory) {
        return this.beHistoryDao.queryAll(beHistory);
    }

    @Override
    public List<Map<String, Object>> queryOrid(BeHistory beHistory) {
        return this.beHistoryDao.queryOrid(beHistory);
    }


    /**
     * 新增数据
     *
     * @param beHistory 实例对象
     * @return 实例对象
     */
    @Override
    public BeHistory insert(BeHistory beHistory) {
        this.beHistoryDao.insert(beHistory);
        return beHistory;
    }

    /**
     * 修改数据
     *
     * @param beHistory 实例对象
     * @return 实例对象
     */
    @Override
    public BeHistory update(BeHistory beHistory) {
        this.beHistoryDao.update(beHistory);
        return this.queryById(beHistory.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.beHistoryDao.deleteById(id) > 0;
    }
}